close all;
clear all;
clc;
interval = [-30 30];

mu1=-6;
sigma1=sqrt(30);
mu2=4;
sigma2=sqrt(10);

x_stern = (mu2*sigma1 + mu1*sigma2)/(sigma1+sigma2);

disp(['x* =' num2str(x_stern)]);
disp(['1 - F_1(x*) = ' num2str(1-normcdf(x_stern,mu1,sigma1))]);
disp(['F_2(x*) = ' num2str(normcdf(x_stern,mu2,sigma2))]);
 
plotCDF(mu1,sigma1,1);
hold all;
plotCDF(mu2,sigma2);

X = linspace(interval(1),interval(2),5000);
Y1 = 1 - normcdf (X,mu1,sigma1);
Y2 = normcdf (X,mu2,sigma2);

index = find (Y1 < Y2, 1, 'first');
plot ([X(index) X(index)],[0 1],'k--');

plot (x_stern,normcdf(x_stern,mu2,sigma2),'r*');
grid on;
legend('1 - CDF_1','CDF_2','Graphical Decision Boundary','Calculated Decision Boundary: x*');
